{include file="public/header" /}
<style>
    .layui-input-inline{
        margin-top: 5px;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">
                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" id="key" class="layui-input search" name="key" value="" placeholder="店铺名/手机号"/>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="quid" lay-search="">
                                <option  value="">不限区域</option>
                                {volist name='quuus' id='q'}
                                <option  value="{$q.district_id}">{$q.district}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="binds" lay-search="">
                                <option  value="">不限绑定状态</option>
                                <option  value="1">未绑定</option>
                                <option  value="2">已绑定</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="dabiao" lay-search="">
                                <option  value="">不限达标状态</option>
                                <option  value="1">未达标</option>
                                <option  value="2">已达标</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="butie" lay-search="">
                                <option  value="">不限补贴状态</option>
                                <option  value="1">未补贴</option>
                                <option  value="2">已补贴</option>
                            </select>
                        </div>
                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" id="start" class="layui-input search" value="{$month}" name="start" onclick="wk.lay_date2(this);" readonly  placeholder="年月开始"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" id="end" class="layui-input search" name="end" value="{$month}" onclick="wk.lay_date2(this);" readonly  placeholder="年月结束"/>
                        </div>
                        <div class="layui-input-inline">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>
                <!--搜索框结束-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <input type="text" disabled class="layui-input" id="tongji1" value="" style="border:1px solid red;color: red;width: 400px;" />
                    </div>
                </div>
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--操作模板-->
                    <script type="text/html" id="bind">
                        {{# if(d.ss_bindtime){ }}
                        <span style="color: mediumseagreen;">已绑定</span>
                        {{# }else{ }}
                        未绑定
                        {{# } }}
                    </script>
                    <script type="text/html" id="done">
                        {{# if(d.record_pay_month_done == 1){ }}
                        <span style="color: gray;">未达标</span>
                        {{# } }}
                        {{# if(d.record_pay_month_done == 2){ }}
                        <span style="color: mediumseagreen;">已达标</span>
                        {{# } }}
                    </script>
                    <script type="text/html" id="shop_butie">
                        {{# if(d.shop_butie == 1){ }}
                        <span style="color: gray;">未补贴</span>
                        {{# } }}
                        {{# if(d.shop_butie == 2){ }}
                        <span style="color: mediumseagreen;">已补贴</span>
                        {{# } }}
                    </script>
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.href('{:url('recordList')}?id={{d.shop_id}}&month={{d.record_pay_month}}')" class="btn btn-info btn-xs m-r-xs" >收款记录</a>
                        {{# if(d.shop_butie == 1 && d.record_pay_month_done == 2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.shop_id}}','{:url('butieDone')}','确定已经补贴了吗?')" class="btn btn-warning btn-xs m-r-xs" title="完成补贴">完成补贴</a>
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
            , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Tongji/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: 10
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type:'numbers', width: 80, title: '序号'}
//                , {field: 'record_shop_id', width: '', title: '店铺ID', align: 'center'}
                , {field: 'shop_name', width: '', title: '店铺名', align: 'center'}
                , {field: 'shop_contact', width: '', title: '手机号', align: 'center'}
                , {field: 'record_pay_month', width: '', title: '年月', align: 'center'}
                , {field: 'nums', width: '100', title: '订单量', align: 'center'}
                , {field: 'money', width: '', title: '成交额', align: 'center'}
                , {field: 'ss_bindtime', width: '', title: '绑定时间', align: 'center'}
                , {field: 'dailiname', width: '', title: '所属代理', align: 'center'}
                , {field: 'days', width: '80', title: '倒计时', align: 'center'}
                , {field: 'ss_bindtime',fixed:'right', width: '90', title: '绑定状态', align: 'center',toolbar: '#bind'}
                , {field: 'record_pay_month_done',fixed:'right', width: '90', title: '达标状态', align: 'center',toolbar: '#done'}
                , {field: 'shop_butie',fixed:'right', width: '90', title: '是否补贴', align: 'center',toolbar: '#shop_butie'}
                , {fixed: 'right', width: 180, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]],
            done:function (res, curr, count) {
                $(".table-img").viewer();
                $('#tongji1').val('当前条件下总金额：'+res.allmoney+'元');
            }
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 1: num = 2;
            //用户状态
            wk.status(this.value,num, '{:url("shopStatus")}',obj);
        });
        //监听状态开关操作
        form.on('switch(OnOff1)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 1: num = 2;
            //用户状态
            wk.status(this.value,num, '{:url("shopStatus1")}',obj);
        });
    });

    function son(shop_id) {
        layer.prompt({
            formType: 2,
            title: '填写子账号',
            area: ['200px', '50px'],
            btn: ['确认', '取消'],
            maxlength:11,
        },function(value, index, elem){
            var pattern = /^1[34578]\d{9}$/;
            if(!pattern.test(value)){
                wk.error('请填写正确的手机号');
                return;
            }
            send(shop_id,value);
            layer.close(index);
        });
    }
    function send(shop_id,value){
        $.ajax({
            url: "{:url('addSon')}",
            type: "post",
            dataType: "json",
            data: {shop_id:shop_id,value:value},
            success: function (res) {
                if(res.code == 200){
                    layer.msg(res.msg,{icon:1,time:1500,shade: 0.1},function(){
                        //重载当前页表格
                        $(".layui-laypage-btn").click();
                    });
                } else if (res.code == 100){
                    layer.msg(res.msg,{icon:2,time:1500,shade: 0.1});
                }
            }
        });
    }
</script>
</body>
</html>